package fr.emse.tatiana.filter;

import java.io.*;

public class CatWriter extends BufferedWriter {
	
	private boolean firstline;
	
	public CatWriter(String outname) throws IOException {
		super(new FileWriter(outname));
		firstline=true;
	}
	
	public void add(String filename) throws IOException {
		BufferedReader reader = new BufferedReader(new FileReader(filename));
		for (String s = reader.readLine(); s!=null; s=reader.readLine()) {
			if (firstline) {
				firstline=false;
			} else {
				this.write("\n");
			}
			this.write(s);
		}
	}

}
